package com.audition.thread;

/**
 * @author ADMIN
 * @date 2021/3/7 20:44
 */
public class StopRunnable {

    public static void main(String[] args) throws InterruptedException {
        Runnable runnable = () -> {
            int num = 0;
            while (!Thread.currentThread().isInterrupted() && num <= 1000) {
                System.out.println(num);
                num++;
                try {
                    Thread.sleep(100000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
        Thread.sleep(5);
        thread.interrupt();

    }


}
